using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using NetWorkMsg;
using NetMsg.Player;

namespace NetMsg.CardAction
{
    // 动作目标类型
    public enum ActionTargetType
    {
        Card,
        Crystal,
    }
    
    // 动作目标信息
    public struct ActionTarget : IUnPackable
    {
        public bool IsOffensive;
        public ActionTargetType Type;
        public int Position;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out IsOffensive);
            UnPackAuxiliary.Read(stream, out uint var0);
            Type = (ActionTargetType)var0;
            UnPackAuxiliary.Read(stream, out uint var1);
            Position = (int)var1;
        }
    }
    
    // 战场信息
    public class BattlefieldInfo : IUnPackable
    {
        // 战场Id
        public int BattleId;
        // 先手
        public long Offensive;
        // 对方
        public PlayerSummary Enemy;
        
        public virtual void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            BattleId = (int)var0;
            UnPackAuxiliary.Read(stream, out ulong var1);
            Offensive = (long)var1;
            Enemy = new PlayerSummary();
            Enemy.UnPack(stream);
        }
    }
    
    // 玩家信息
    public class BattleFighterInfo : IUnPackable
    {
        // 体力
        public int Stamina;
        // 牌组
        public List<int> Deck;
        // 手牌
        public List<int> Hand;
        // 水晶
        public List<int> Crystal;
        // 场上
        public List<int> Board;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            Stamina = (int)var0;
            UnPackAuxiliary.ReadUsAsIs(stream, out Deck);
            UnPackAuxiliary.ReadUsAsIs(stream, out Hand);
            UnPackAuxiliary.ReadUsAsIs(stream, out Crystal);
            UnPackAuxiliary.ReadUsAsIs(stream, out Board);
        }
    }
    
    public class BattlefieldDetailInfo : BattlefieldInfo
    {
        // 对手      
        public BattleFighterInfo Opponent;
        public BattleFighterInfo Self;
        
        public override void UnPack(MemoryStream stream)
        {
            base.UnPack(stream);
            Opponent = new BattleFighterInfo();
            Opponent.UnPack(stream);
            Self = new BattleFighterInfo();
            Self.UnPack(stream);
        }
    }
    
    // 进入战斗
    public class ActionEnterSummaryP : IUnPackable
    {
        public BattlefieldInfo Info;
        
        public const uint Sid = 99;
        
        public void UnPack(MemoryStream stream)
        {
            Info = new BattlefieldInfo();
            Info.UnPack(stream);
        }
    }
    
    // 进入战斗
    public class ActionEnterDetailP : IUnPackable
    {
        public BattlefieldDetailInfo Info;
        
        public const uint Sid = 100;
        
        public void UnPack(MemoryStream stream)
        {
            Info = new BattlefieldDetailInfo();
            Info.UnPack(stream);
        }
    }
    
    // 开始选牌
    public struct ActionBeginPickP : IUnPackable
    {
        // 选牌结束时间
        public int TimeStamp;
        
        public const uint Sid = 101;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            TimeStamp = (int)var0;
        }
    }
    
    // 通知选牌结束,如果数组为空,则说明不需要修改牌组
    public class ActionPickUpEndP : IUnPackable
    {
        // 手牌
        public List<int> Hand;
        // 牌组
        public List<int> Deck;
        
        public const uint Sid = 102;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.ReadUsAsIs(stream, out Hand);
            UnPackAuxiliary.ReadUsAsIs(stream, out Deck);
        }
    }
    
    // 回合开始
    public struct ActionTurnBeginP : IUnPackable
    {
        // 是否是先手局
        public bool IsOffensive;
        
        public const uint Sid = 103;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out IsOffensive);
        }
    }
    
    public struct ActionTurnBeginEndP : IUnPackable
    {
        
        public const uint Sid = 104;
        
        public void UnPack(MemoryStream stream)
        {
        }
    }
    
    // 进入回合
    public struct ActionEnterTurnP : IUnPackable
    {
        // 回合结束时间
        public int TimeStamp;
        
        public const uint Sid = 105;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            TimeStamp = (int)var0;
        }
    }
    
    // 开始自动战斗
    public struct ActionAutoFightP : IUnPackable
    {
        
        public const uint Sid = 106;
        
        public void UnPack(MemoryStream stream)
        {
        }
    }
    
    // 自动战斗结束
    public struct ActionAutoFightEndP : IUnPackable
    {
        
        public const uint Sid = 107;
        
        public void UnPack(MemoryStream stream)
        {
        }
    }
    
    // 抽牌(自己)
    public class ActionPickUpSP : IUnPackable
    {
        public List<int> Picks;
        
        public const uint Sid = 108;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.ReadUsAsIs(stream, out Picks);
        }
    }
    
    // 抽牌(对方)
    public struct ActionPickUpEP : IUnPackable
    {
        public int Number;
        
        public const uint Sid = 109;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            Number = (int)var0;
        }
    }
    
    // 放牌
    public struct ActionPutOnP : IUnPackable
    {
        public bool IsOffensive;
        public int Position;
        public int CardId;
        
        public const uint Sid = 110;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out IsOffensive);
            UnPackAuxiliary.Read(stream, out uint var0);
            Position = (int)var0;
            UnPackAuxiliary.Read(stream, out uint var1);
            CardId = (int)var1;
        }
    }
    
    // 攻击
    public struct ActionAttackP : IUnPackable
    {
        public bool IsOffensive;
        // 攻击的卡的位置
        public int Position;
        public ActionTarget Target;
        
        public const uint Sid = 111;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out IsOffensive);
            UnPackAuxiliary.Read(stream, out uint var0);
            Position = (int)var0;
            Target = new ActionTarget();
            Target.UnPack(stream);
        }
    }
    
    // 卡牌属性类型
    public enum ActionPropertyType
    {
        Attack,
        Health,
    }
    
    // 属性修改(原属性 += Value)
    public struct ActionPropertyChangeP : IUnPackable
    {
        public ActionTarget Target;
        public ActionPropertyType Type;
        public int Value;
        
        public const uint Sid = 112;
        
        public void UnPack(MemoryStream stream)
        {
            Target = new ActionTarget();
            Target.UnPack(stream);
            UnPackAuxiliary.Read(stream, out uint var0);
            Type = (ActionPropertyType)var0;
            UnPackAuxiliary.Read(stream, out Value);
        }
    }
    
    // 设置属性(原属性 = Value)
    public struct ActionSetPropertyP : IUnPackable
    {
        public ActionTarget Target;
        public ActionPropertyType Type;
        public int Value;
        
        public const uint Sid = 113;
        
        public void UnPack(MemoryStream stream)
        {
            Target = new ActionTarget();
            Target.UnPack(stream);
            UnPackAuxiliary.Read(stream, out uint var0);
            Type = (ActionPropertyType)var0;
            UnPackAuxiliary.Read(stream, out Value);
        }
    }
    
    // 卡牌死亡
    public struct ActionDeadP : IUnPackable
    {
        public bool IsOffensive;
        public int Position;
        
        public const uint Sid = 114;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out IsOffensive);
            UnPackAuxiliary.Read(stream, out uint var0);
            Position = (int)var0;
        }
    }
    
    // 墓地召回(己方)
    public struct ActionReviveSP : IUnPackable
    {
        public int CardId;
        
        public const uint Sid = 115;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            CardId = (int)var0;
        }
    }
    
    // 墓地召回(敌方)
    public struct ActionReviveEP : IUnPackable
    {
        
        public const uint Sid = 116;
        
        public void UnPack(MemoryStream stream)
        {
        }
    }
    
    // 返回手牌
    public struct ActionBackP : IUnPackable
    {
        public bool IsOffensive;
        public int Position;
        
        public const uint Sid = 117;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out IsOffensive);
            UnPackAuxiliary.Read(stream, out uint var0);
            Position = (int)var0;
        }
    }
    
    // 卡牌移动
    public struct ActionMoveP : IUnPackable
    {
        public bool IsOffensive;
        public int CurrentPos;
        public int NewPos;
        
        public const uint Sid = 118;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out IsOffensive);
            UnPackAuxiliary.Read(stream, out uint var0);
            CurrentPos = (int)var0;
            UnPackAuxiliary.Read(stream, out uint var1);
            NewPos = (int)var1;
        }
    }
    
    // 增加行动点上限
    public struct ActionModifyStaminaLimitP : IUnPackable
    {
        public bool IsOffensive;
        public int Value;
        
        public const uint Sid = 119;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out IsOffensive);
            UnPackAuxiliary.Read(stream, out uint var0);
            Value = (int)var0;
        }
    }
    
    // 行动点修改
    public struct ActionModifyStaminaP : IUnPackable
    {
        public bool IsOffensive;
        public int Value;
        
        public const uint Sid = 120;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out IsOffensive);
            UnPackAuxiliary.Read(stream, out Value);
        }
    }
    
    // 动作Buff目标类型
    public enum ActionBuffType
    {
        // 卡牌
        Card,
        // 位置
        Position,
    }
    
    // 动作目标信息
    public struct ActionBuff : IUnPackable
    {
        public bool IsOffensive;
        // 对应的技能Id
        public int SkillId;
        public ActionBuffType Type;
        public int Position;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out IsOffensive);
            UnPackAuxiliary.Read(stream, out uint var0);
            SkillId = (int)var0;
            UnPackAuxiliary.Read(stream, out uint var1);
            Type = (ActionBuffType)var1;
            UnPackAuxiliary.Read(stream, out uint var2);
            Position = (int)var2;
        }
    }
    
    // 技能目标类型(因为技能能作用的对象比Buff多,现在如果混用的话,之后不好修改)
    public enum ActionSkillType
    {
        // 卡牌
        Card,
        // 位置
        Position,
    }
    
    // 技能目标
    public struct ActionSkillTarget : IUnPackable
    {
        public bool IsOffensive;
        public ActionSkillType Type;
        public int Position;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out IsOffensive);
            UnPackAuxiliary.Read(stream, out uint var0);
            Type = (ActionSkillType)var0;
            UnPackAuxiliary.Read(stream, out uint var1);
            Position = (int)var1;
        }
    }
    
    // 使用技能
    public class ActionUseSkillP : IUnPackable
    {
        public bool IsOffensive;
        // 卡牌的位置
        public int Position;
        public List<ActionSkillTarget> Targets;
        
        public const uint Sid = 121;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out IsOffensive);
            UnPackAuxiliary.Read(stream, out uint var0);
            Position = (int)var0;
            UnPackAuxiliary.Read(stream, out uint var1);
            Targets = new List<ActionSkillTarget>((int)var1);
            for(var i = 0; i < var1; ++i)
            {
                var var2 = new ActionSkillTarget();
                var2.UnPack(stream);
                Targets.Add(var2);
            }
        }
    }
    
    // 添加Buff
    public class ActionAddBuffP : IUnPackable
    {
        public ActionBuff Buff;
        
        public const uint Sid = 122;
        
        public void UnPack(MemoryStream stream)
        {
            Buff = new ActionBuff();
            Buff.UnPack(stream);
        }
    }
    
    // 触发Buff
    public class ActionTriggerBuffP : IUnPackable
    {
        public ActionBuff Buff;
        
        public const uint Sid = 123;
        
        public void UnPack(MemoryStream stream)
        {
            Buff = new ActionBuff();
            Buff.UnPack(stream);
        }
    }
    
    // 移除Buff
    public class ActionRmvBuffP : IUnPackable
    {
        public ActionBuff Buff;
        
        public const uint Sid = 124;
        
        public void UnPack(MemoryStream stream)
        {
            Buff = new ActionBuff();
            Buff.UnPack(stream);
        }
    }
    
    // 比赛结束类型
    public enum ActionMatchOverType
    {
        // 平局
        Tied,
        // 对方输了
        TargetLost,
        // 对方投降
        TargetSurrender,
    }
    
    // 比赛结束
    public struct ActionMatchOverP : IUnPackable
    {
        public ActionMatchOverType Type;
        // 获胜者Id
        public long WinnerId;
        
        public const uint Sid = 125;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            Type = (ActionMatchOverType)var0;
            UnPackAuxiliary.Read(stream, out ulong var1);
            WinnerId = (long)var1;
        }
    }
    
    public enum CardActionEnum
    {
        ActionEnterSummaryP,
        ActionEnterDetailP,
        ActionBeginPickP,
        ActionPickUpEndP,
        ActionTurnBeginP,
        ActionTurnBeginEndP,
        ActionEnterTurnP,
        ActionAutoFightP,
        ActionAutoFightEndP,
        ActionPickUpSP,
        ActionPickUpEP,
        ActionPutOnP,
        ActionAttackP,
        ActionPropertyChangeP,
        ActionSetPropertyP,
        ActionDeadP,
        ActionReviveSP,
        ActionReviveEP,
        ActionBackP,
        ActionMoveP,
        ActionModifyStaminaLimitP,
        ActionModifyStaminaP,
        ActionUseSkillP,
        ActionAddBuffP,
        ActionTriggerBuffP,
        ActionRmvBuffP,
        ActionMatchOverP,
    }
}
